function double(value) {
  setTimeout(() => setTimeout(console.log, 0, value * 2), 1000);
}
// double(3);

function bar(val, callback) {
  setTimeout(() => {
    let param = val * val + 25;
    callback(param);
  })
}

let outerParam = '';

function foo(val) {
  outerParam = val;
  console.log(val);
  console.log('outParam-1:' + outerParam);
}
bar(3, foo);
console.log('outParam-2:' + outerParam);
//成功回调与失败回调
function func(val, successCallback, failUreCallback) {
  setTimeout(() => {
    try {
      if (typeof val !== 'number') {
        throw 'MUST PROVIDE A NUMBER FOR ARGUMENT';
      }
      successCallback(val ** 2);
    } catch (e) {
      failUreCallback(e);
    }
  }, 1000)
}
const successFunc = (val) => {
  console.log(`Success ${val}`);
}
const successFunc1 = (val) => {
  func(val, (y) => {
    console.log(`Success1 ${y}`);
  })
}
const failureFunc = (val) => {
  console.log(`Failure ${val}`);
}
func(5, successFunc, failureFunc);
func('abc', successFunc, failureFunc);
func(5, successFunc1, failureFunc);
func('abc', successFunc1, failureFunc)